#ifndef FORMATTEDEDITOR_H
#define FORMATTEDEDITOR_H

#include "editor.h"
#include "Editor/formattingtoolbar.h"
#include <QToolBar>

QT_BEGIN_NAMESPACE
	class QFontComboBox;
	class QComboBox;
	class QAction;
QT_END_NAMESPACE

class FormattingToolBar;

class FormattedEditor : public Editor
{
	Q_OBJECT

	public:
		FormattedEditor(DocumentManager *newManager);

		Type getType() const { return FORMATTED; }
		static bool isFormattedFile(const QString fileName);
		void saveFile();
		
		virtual void saveFile(QString);        //Save out actual file information
		virtual void saveFile(QByteArray&);		//Create a QByteArray of the data to be saved
		virtual QString saveSession(QString);     //Initiate the saving process and grab other variables.
		virtual void loadSession(QString filename, QStringList metadata);
		virtual void loadFile(QString);
		virtual void loadFile(QByteArray);
		virtual void setMeta(QStringList);
		virtual QString getMeta();

		void receiveChange(QByteArray change);
		void handleAddTextChange(QByteArray change);
		void handleHtmlTextChange(QByteArray change);
		void handleRemoveTextChange(QByteArray change);
		void handleFormatChange(QByteArray change);
		void handleAddTableChange(QByteArray change);
		void handleAddImageChange(QByteArray change);

	public slots:
		virtual void textChanged(int position, int charsRemoved, int charsAdded);
		void checkForTabOnList(int position, int charsRemoved, int charsAdded);

		//overrides for toolbar-used functions to send changes on selections
		void setFontWeight(int weight);
		void setFontItalic(bool italic);
		void setFontUnderline(bool underline);
		void setFontPointSize(qreal s);
		void setCurrentFont(const QFont &f);
		void setTextColor(const QColor & c);
		void setTextBackgroundColor(const QColor & c);
		void setAlignment(Qt::Alignment a);
		void toggleList(bool listOn, int style);
		void handleListChange(QTextCursor cursor, int style);
		void insertTable(int rows, int cols);
		void insertImage(QString fname);

	protected:
		void resizeEvent(QResizeEvent *event);
		void insertFromMimeData(const QMimeData *source);

	private:
		static const int TOOLBAR_HEIGHT;

		QString fileName;
		FormattingToolBar *toolBar;

};

#endif // FORMATTEDEDITOR_H
